(
    function () {
       //Background背景类的构造函数的定义以及暴露全局
      var Background = window.Background = function () {
        //定义Background的背景图
        this.imgrandom = parseInt(Math.random() * 2);
        this.imgArr = [game.imgS.bg_day,game.imgS.bg_night];
        this.img = this.imgArr[this.imgrandom];
        this.x = 0;
        this.speed = 100;  //定义图片往左移动的速度
      };
      //Background背景构造函数的渲染背景方法
      Background.prototype.render = function () {
        var imgY = myCanvas.height * 0.78 - 396;  //保存比列 Y的起始位置是响应式根据设备视口变化
        //保存图片的宽高,图片在设备上都是响应式的，背景图无法填充背景，需要猫腻图来填充,猫腻图要填充的就是imgW，
        var imgW = 288;
        var imgH = 512;
        game.ctx.clearRect(0, 0, 1000, 1000);
        game.ctx.drawImage(this.img, this.x, imgY);
        //需要两张猫腻图
        game.ctx.drawImage(this.img, this.x + imgW , imgY);
        game.ctx.drawImage(this.img, this.x + imgW + imgW, imgY);

      if (this.img == game.imgS.bg_night) {
        //填充上面的天空矩形,填充的y长度是比例留出来的
        game.ctx.fillStyle = "#008793";
        game.ctx.fillRect(0, 0, myCanvas.width, imgY + 10);
        game.ctx.fillStyle = "#00a300";
        game.ctx.fillRect(0, myCanvas.height - imgY-10, myCanvas.width, imgY);
      }else {
        //填充上面的天空矩形,填充的y长度是比例留出来的
        game.ctx.fillStyle = "#4ec0ca";
        game.ctx.fillRect(0, 0, myCanvas.width, imgY + 10);
        // game.ctx.fillStyle = "#5ee270";
        // game.ctx.fillRect(0, myCanvas.height - imgY-10, myCanvas.width, imgY);
      }
        //填充下面草地的，填充从canvas.height - imgY


      };
      //Background背景构造函数的更新背景
      Background.prototype.update = function () {
        this.x -= this.speed;  //每一次的定时器都调用update，使图片的x坐标减去一次次速度,这样图片会往左移动
        if (this.x < -288){
          this.x = 0;
        }

      }


    }


)();